package com.sunjy.demo1.ServicesImpl;

import java.util.List;

import com.alicp.jetcache.anno.Cached;
import com.sunjy.demo1.form.UserForm;
import com.sunjy.demo1.service.TestServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sunjy.common.domain.ApiResponseT;
import com.sunjy.demo1.mapper.TestNameMapper;
import com.sunjy.demo1.model.TestName;

import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;

@Service
@Slf4j
public class TestServicesImpl implements TestServices {
	
	@Autowired
	private TestNameMapper testNameMapper;
	
	public ApiResponseT test1(){
		log.info("testsercives日志");
		List<TestName> list=testNameMapper.selectAll();
		return ApiResponseT.success(list);
	}

	@Override
	@Transactional
	@Cached(name="UserService",key="#userForm.id+#userForm.name", expire = 3600)
	public ApiResponseT testCache(UserForm userForm) {

		TestName testName=new TestName();
		testName.setName("胡");
		testNameMapper.insert(testName);
		List<TestName> list=testNameMapper.selectAll();
		return ApiResponseT.success(list);
	}

}
